package com.syg.Services;

import com.syg.Interface.InterfaceSpi;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author oe_shenyiguang
 * @date 2021年10月8日10:15:42
 * @version 1.0
 */
@Service
public class SpiImpl {

    @PostConstruct
    public void printService(){
        List<String> serviceNames = SpringFactoriesLoader.loadFactoryNames(InterfaceSpi.class,null);
        for (String serviceName:serviceNames){
            System.out.println(serviceName);
        }

        List<InterfaceSpi> services = SpringFactoriesLoader.loadFactories(InterfaceSpi.class,null);
        for (InterfaceSpi demoService:services){
            demoService.printName();
        }
    }
}
